package com.trkj.dao.jpa;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.CcPatient;

public interface CcPatientDAO extends CrudRepository<CcPatient,Long> {

	@Query("select c from CcPatient c where c.paberthid is null and c.premarks<>'已出院' order by c.ppdate desc")
	public List<CcPatient> findBypaberthidnull(Pageable pageable);
	@Query("select c from CcPatient c where c.paberthid is not null and c.premarks<>'已出院' order by c.ppdate desc")
	public List<CcPatient> findByPaberthidnotnull(Pageable pageable);
	@Query("select count(*) from CcPatient c where c.paberthid is not null and c.premarks<>'已出院' ")
	public long findBypaberthidnotnullCount();
	@Query("select count(*) from CcPatient c where c.paberthid is  null and c.premarks<>'已出院'")
	public long findBypaberthidnullCount();
	@Query("select c from CcPatient c where c.premarks<>'已出院' order by c.ppdate desc")
	public List<CcPatient> findByAllCcPatient(Pageable pageable);
	@Query("select c from CcPatient c  where c.premarks<>'已出院'")
	public  List<CcPatient> findAllCcPatient();
	@Query("select c from CcPatient c  where c.icid=?1 and c.premarks<>'已出院'")
	public CcPatient findByOneCcPatient(BigDecimal icid);
	@Query("select c from CcPatient c  where c.patientid=?1 and c.premarks<>'已出院'")
	public CcPatient findByOneCcPatientid(long id);
	//BigDecimal padoctorid
	@Query("select c from CcPatient c  where c.padoctorid=?1 and c.premarks<>'已出院' order by c.ppdate desc")
	public List<CcPatient> findBypadoctorid(BigDecimal padoctorid);
	@Query("select c from CcPatient c  where c.pname like %?1% and c.premarks<>'已出院' order by c.ppdate desc")
	public List<CcPatient> findBypname(String pname);
}
